Skip to content

Conversation

@deepin-ci-robot
Copy link
Contributor

Synchronize source files from linuxdeepin/qt5platform-plugins.

Source-pull-request: linuxdeepin/qt5platform-plugins#300

Synchronize source files from linuxdeepin/qt5platform-plugins.

Source-pull-request: linuxdeepin/qt5platform-plugins#300
@deepin-ci-robot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

根据提供的代码差异,我来分析一下这些变更的合理性和改进建议:

1. 代码质量和安全性改进

  1. 移除不必要的Q_DECL_HIDDEN宏

    • 在dnativesettings.h、dplatformsettings.h、dxcbxsettings.h中移除了Q_DECL_HIDDEN宏
    • 改进建议:这是合理的,因为这些类可能是API的一部分,隐藏它们可能会影响外部使用。建议保持这些类的可见性。
  2. 添加[[maybe_unused]]标记

    • 在ddesktopinputselectioncontrol.cpp、dxcbxsettings.cpp、vtablehook.h等文件中为未使用的函数参数添加了[[maybe_unused]]
    • 改进建议:这是一个好的实践,可以避免编译器警告,同时明确表示这些参数是有意未使用的。
  3. 移除未使用的变量

    • 在dbackingstoreproxy.cpp中移除了未使用的byte_count变量
    • 改进建议:这是合理的,移除未使用的变量可以提高代码的清晰度。

2. 代码逻辑和性能改进

  1. VtableHook类中的条件判断优化

    // 修改前
    if (fun1_offset < 0 || fun1_offset > UINT_LEAST16_MAX)
    // 修改后
    if (fun1_offset > UINT_LEAST16_MAX)
    • 改进建议:这是合理的优化,因为fun1_offset是通过toQuintptr(&fun1)得到的,而quintptr是无符号类型,不可能小于0。
  2. DWaylandInterfaceHook中的类型安全改进

    // 修改前
    return window->property(::supportForSplittingWindow).toInt() >= screenSplittingType;
    // 修改后
    int propertyValue = window->property(::supportForSplittingWindow).toInt();
    return propertyValue >= 0 && static_cast<quint32>(propertyValue) >= screenSplittingType;
    • 改进建议:这是很好的改进,增加了对propertyValue的负数检查,确保类型转换的安全性。
  3. DHighDpi::onDPIChanged函数改进

    • 添加了更多Q_UNUSED标记
    • 改进建议:这是合理的,因为这些参数在某些情况下可能未使用,但保留它们以保持接口一致性。

3. 潜在问题和建议

  1. DPlatformBackingStoreHelper中的版本特定代码

    #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
    QXcbShmImage *shm_image = reinterpret_cast<QXcbShmImage*>(bs->m_image);
    #else
    struct _QXcbBackingStore { QImage *m_image; };
    QXcbShmImage *shm_image = reinterpret_cast<QXcbShmImage*>(reinterpret_cast<_QXcbBackingStore*>( &bs )->m_image);
    #endif
    • 改进建议:这种依赖Qt版本的方式可能导致维护困难。建议考虑使用Qt的插件系统或运行时检查来处理不同版本间的差异。
  2. 测试类中的GTEST_API_标记

    • 在测试类中添加了GTEST_API_标记
    • 改进建议:这是合理的,可以确保测试类在所有编译配置中都正确可见。

4. 总体评价

这些变更总体上是积极的,主要关注:

  1. 提高代码安全性(如类型检查)
  2. 改进代码质量(如移除未使用变量)
  3. 增强代码可维护性(如使用[[maybe_unused]])

建议:

  1. 继续关注代码版本兼容性问题,考虑使用更灵活的解决方案
  2. 在处理底层平台代码时,添加更多的错误检查和边界条件处理
  3. 考虑添加更多的单元测试来覆盖这些关键路径

这些改进有助于提高代码的健壮性和可维护性,特别是在处理跨平台和不同Qt版本时。

@18202781743 18202781743 merged commit fe42fd3 into master Aug 18, 2025
32 of 33 checks passed
@18202781743 18202781743 deleted the sync-pr-300-nosync branch August 18, 2025 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants